package cn.csc.module.system.api.ip;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.framework.ip.core.CompanyCode;
import cn.csc.framework.ip.core.utils.KuaiDi100CompanyCodeUtils;
import cn.csc.module.system.api.ip.dto.CompanyCodeDto;
import cn.csc.module.system.convert.ip.CompanyCodeConvert;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static cn.csc.framework.common.pojo.CommonResult.success;
import static cn.csc.module.system.enums.ApiConstants.VERSION;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@DubboService(version = VERSION) // 提供 Dubbo RPC 接口，给 Dubbo Consumer 调用
@Validated
public class KuaiDi100CompanyCodeApiImpl implements  KuaiDi100CompanyCodeApi{

    @Override
    public CommonResult<CompanyCodeDto> getByCode(String code) {
        CompanyCode byCode = KuaiDi100CompanyCodeUtils.getByCode(code);

        return success(CompanyCodeConvert.INSTANCE.convert(byCode));
    }
}
